const express = require("express")
const path = require('path')
const Charts = require('./controller/charts')
const mkdirp = require("mkdirp");

const app = express()

app.use(express.static(path.join(__dirname, "./static")))

app.use(express.urlencoded({extended: true}))
app.use(express.json())
app.set("view engine", "ejs")
app.set("views", path.resolve(__dirname, "views"))

app.get("/", (req, res, next) => {
  res.send("hello world!")
})

app.get("/previewChart", (req, res, next) => {
  res.render("charts")
})

app.get("/url", Charts.renderUrlChart)

app.post("/createEcharts", Charts.renderChart)

app.listen(3000, () => {
  console.log("服务器已经启动！")
})
